package LLY.lly.item;

import LLY.lly.block.BlockRegistryHandler;
import LLY.lly.lly;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.registries.IForgeRegistry;

@Mod.EventBusSubscriber
public class ItemRegistryHandler {


    public static final Item.ToolMaterial LIANG_TOOL_MATERIAL = EnumHelper.addToolMaterial(
            "LIANG", 3, 20101011, 3.0F, 10.0F, 5);

    public static final ItemArmor.ArmorMaterial LIANG_ARMOR_MATERIAL = EnumHelper.addArmorMaterial(
            "LIANG", lly.MODID + ":liang", 20, new int[] {5, 10, 10, 5}, 9, SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, 0);


    public static final ItemLiangBall LIANG_BALL = new ItemLiangBall();
    public static final ItemLiang LIANG = new ItemLiang();
    public static final ItemLiangPickaxe LIANG_PICKAXE = new ItemLiangPickaxe();
    public static final ItemLiangArmor LIANG_BOOTS = new ItemLiangArmor(EntityEquipmentSlot.FEET);
    public static final ItemLiangArmor LIANG_LEGGINGS = new ItemLiangArmor(EntityEquipmentSlot.LEGS);
    public static final ItemLiangArmor LIANG_CHESTPLATE = new ItemLiangArmor(EntityEquipmentSlot.CHEST);
    public static final ItemLiangArmor LIANG_HELMET = new ItemLiangArmor(EntityEquipmentSlot.HEAD);

    @SubscribeEvent
    public static void onRegistry(RegistryEvent.Register<Item> event) {
        IForgeRegistry<Item> registry = event.getRegistry();
        registry.register(LIANG_BALL);
        registry.register(LIANG);
        registry.register(LIANG_PICKAXE);
        registry.register(LIANG_BOOTS);
        registry.register(LIANG_LEGGINGS);
        registry.register(LIANG_CHESTPLATE);
        registry.register(LIANG_HELMET);

        ITEM_BLOCK_Liang.setRegistryName(ITEM_BLOCK_Liang.getBlock().getRegistryName());
        registry.register(ITEM_BLOCK_Liang);

        ITEM_BLOCK_Liang_1.setRegistryName(ITEM_BLOCK_Liang_1.getBlock().getRegistryName());
        registry.register(ITEM_BLOCK_Liang_1);

    }

    @SideOnly(Side.CLIENT)
    private static void registerModel(Item item)
    {
        ModelResourceLocation modelResourceLocation = new ModelResourceLocation(item.getRegistryName(), "inventory");
        ModelLoader.setCustomModelResourceLocation(item, 0, modelResourceLocation);
    }
    @SubscribeEvent
    @SideOnly(Side.CLIENT)
    public static void onModelRegistry(ModelRegistryEvent event)
    {

        registerModel(LIANG_BALL);
        registerModel(LIANG);
        registerModel(ITEM_BLOCK_Liang);
        registerModel(LIANG_PICKAXE);
        registerModel(ITEM_BLOCK_Liang_1);
        registerModel(LIANG_BOOTS);
        registerModel(LIANG_LEGGINGS);
        registerModel(LIANG_CHESTPLATE);
        registerModel(LIANG_HELMET);


    }

    public static final ItemBlock ITEM_BLOCK_Liang = new ItemBlock(BlockRegistryHandler.BLOCK_LIANG);
    public static final ItemBlock ITEM_BLOCK_Liang_1 = new ItemBlock(BlockRegistryHandler.BLOCK_LIANG_1);
}
